package com.graduation.smartparkingplatform.ServiceImpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.graduation.smartparkingplatform.Dao.PayingRecordMapper;
import com.graduation.smartparkingplatform.Pojo.PayingRecord;
import com.graduation.smartparkingplatform.Service.PayingRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PayingRecordServiceImpl implements PayingRecordService {

  @Autowired PayingRecordMapper payingRecordMapper;

  // 获取支付记录列表（分页）
  @Override
  public PageInfo<PayingRecord> getpayingRecordList(Integer page, Integer count) {
    PageHelper.startPage(page, count);

    List<PayingRecord> getpayingRecordList = payingRecordMapper.getpayingRecordList();

    PageInfo<PayingRecord> pageInfo = new PageInfo<>(getpayingRecordList);

    return pageInfo;
  }

  // 模糊搜索支付记录（分页）
  @Override
  public PageInfo<PayingRecord> searchPayingRecord(
      Integer page, Integer count, String outTradeNo, String payStatus) {
    PageHelper.startPage(page, count);

    List<PayingRecord> PayingRecord = payingRecordMapper.searchPayingRecord(outTradeNo, payStatus);

    PageInfo<PayingRecord> pageInfo = new PageInfo<>(PayingRecord);

    return pageInfo;
  }

  // 删除支付记录
  @Override
  public Boolean deletePayingRecord(Integer PayId) {
    return payingRecordMapper.deletePayingRecord(PayId);
  }

  // 获取所有支付记录
  @Override
  public List<PayingRecord> getPayingRecordListAll() {
    return payingRecordMapper.getpayingRecordList();
  }
}
